<?php 
    require_once('inc/conn.php');
 ?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="layui/layui.js"  charset="utf-8"></script>
</head>
<body>
    <form class="layui-form" action="" name="form_add" id="form_add" method="post">
        <table class="layui-table">
            <tr>
                <td colspan="2">管理员列表</td>
            </tr>
            <tr>
                <td height="35">账号</td>
                <td width="25%">操作</td>
            </tr>
            <?php 
                $total_num=mysql_num_rows(mysql_query("SELECT id from admin"));
                $pagesize=2;
                $page_num=ceil($total_num/$pagesize);
                $page=@$_GET['page'];
                if($page<1||$page==''){
                    $page=1;
                }
                if($page>$page_num){
                    $page=$page_num;
                }
                $offset=$pagesize*($page-1);

                $prepage=($page<>1)?$page-1:$page;
                $nextpage=($page<>$page_num)?$page+1:$page;
                $sql="SELECT * FROM admin LIMIT $offset,$pagesize";
                $result=mysql_query($sql);
                while($row=mysql_fetch_array($result)){
                    ?>
                    <tr>
                        <td height="35"><?=$row['user']?></td>
                        <td><input class="layui-btn layui-btn-primary" type="button" onclick="window.location.href='admin_modify.php?id=<?php echo $row['id']?>'" value="修改">&nbsp;&nbsp;
                        <input class="layui-btn layui-btn-primary" type="button" value="删除" onclick="window.location.href='admin_delete.php?id=<?php echo $row['id']?>'"<?php if($row['user']=='admin') { echo "disabled='disabled'";  } ?>>
                        </td>
                    </tr>
                    <?php
                }
             ?>
             <tr>
                 <td height="35" colspan="2" align="center"><?php echo $page?>/<?php echo $page_num ?>&nbsp;&nbsp;<a href="?page=1">首页</a>&nbsp;&nbsp;<a href="?page=<?php echo $prepage?>">上一页</a>&nbsp;&nbsp;<a href="?page=<?php echo $nextpage?>">下一页</a>&nbsp;&nbsp;<a href="?page=<?php echo $page_num?>">尾页</a></td>
             </tr>
        </table>
    </form>
</body>
</html>